/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.axiom.controller;

import com.axiom.persistence.instructor_course_persist;
import com.axiom.persistence.instructor_detail_persist;
import com.axiom.vo.instructor_detail;
import com.axiom.vo.instuctor_course;
import java.util.Date;
import org.hibernate.ScrollableResults;

/**
 *
 * @author Shuhail
 */
public class instructor_details_controller {
    
    
    public static instructor_details_controller getInstance() {
        
        return new instructor_details_controller();
    }
    
    public boolean insertFresh(instructor_detail detail,String courseId) {
        
        boolean succ = instructor_detail_persist.getInstance().insertFresh(detail);
        instuctor_course instcourse = new instuctor_course();
        instcourse.setCourse_id(courseId);
        boolean succ1 = instructor_course_controller.getInstance().insertFresh(instcourse);
        if(succ && succ1) 
            return true;
            else 
            return false;
        }
    
    public int deleteInstructorCourse(String inst_id) {
        
        int instRet = instructor_detail_persist.getInstance().deleteInstructorBasedOnId(inst_id);
        if(instRet!=0) {
            
            int instCourseRet = instructor_course_persist.getInstance().deleteInstructorCourse(inst_id);
            if(instCourseRet!=0) {
                
                return 1;
            }
            else {
                
                return 0;
            }
            
        }
        return 0;
    }
    
    public ScrollableResults getInstructorAndCourse() {
        
        return instructor_detail_persist.getInstance().getIntructorDetailAndCourse();
    }
        

    
    public static void main(String args[]) {
        
        instructor_detail det = new instructor_detail();
        det.setName("Shamu");
        det.setPhone("9567718773");
        det.setDate(new Date());
        int ret =new instructor_details_controller().deleteInstructorCourse("I11");
        System.out.println(ret);
    }
}
    



